<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
     <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>一起新闻 详细页</title>
	<link rel="stylesheet" href="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
	<script src="https://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	
</head>
<script>
function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}

var a=GetRequest();
var index_1=a['id'];
var j = {"newsid":index_1};

$.ajax({
	type : "post",
	url : "<c:url value='/NewsServlet?method=newsSelect'/>",            //servlet需要提前在web.xml里面注册
	dataType : "json",
	data :j,
	success : function(data,textStatus)
	{
        //data为后端post函数传递来的数据，这里写结果操作代码
		var objs = eval(data);  //解析json对象
		
		$("#1").text(objs[0].newstitle); //等你写完，我再补全，这里仅作测试
		$("#1_img").css({"background-image":"url("+objs[0].newsimg+")"});    //objs[1].img  是存储在数据库中的图片路径；
		$("#1_content").html("<embed src="+objs[0].newscontent+" style='width:100%;height:600px'></embed>");
		
		
	},
	error : function(xhr, status, errMsg)
	{
		alert("数据加载失败!");
	}
});



</script>
<style>
.title_img{
    width: 100%;
    height: auto;
    background-size: 100% 100%;
    
}


</style>

<body >
<!-- input id="idcode" value="${id }" -->
<div class="container-fluid text-center title_img" style="height:300px;box-shadow: 5px 5px 5px #888888;background-image:url('image/newstitle.jpg')">
	
	<h1 style="margin-top:240px"><a href="newPage.jsp" style="color:white;">一起新闻网</a></h1>
	
</div>

<div class="container text-center">
	
	<h2 id="1"> news_title</h2>  <!-- 用表单传给我吧  这里用c标签接收参数-->                    <!-- 标题位置 -->
	<br/>
	<div  id='1_img'class=" title_img" style="height:300px;box-shadow: 2px 2px 20px #888888">             <!-- 图片位置 -->
	</div>
	<br/>
	<br/>
	<div id="1_content"  ></div>
</div>